package com.atguigu.yygh.hosp.controller.api;

import com.atguigu.yygh.hosp.result.Result;
import com.atguigu.yygh.hosp.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/hosp")
public class DepartmentApiController {

    @Autowired
    DepartmentService departmentService;

    //http://localhost/api/hosp/saveDepartment
    //上传科室信息

    /**
     * 增加科室信息
     * @param request：HttpServletRequest request
     * @return ：Result.ok()
     */
    @PostMapping("/saveDepartment")
    public Result saveDepartment(HttpServletRequest request){
        departmentService.saveDepartment(request);
        return Result.ok();
    }

    //http://localhost/api/hosp/department/list

    /**
     * 查询Department
     * @param request：HttpServletRequest request
     * @return ：result
     */
    @PostMapping("department/list")
    public Result getDepartmentList(HttpServletRequest request){
        Result result = departmentService.getDepartmentList(request);
        return result;
    }
}
